package cn.lj.controller;

import cn.lj.pojo.Blog;
import cn.lj.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;
import java.util.Map;

/**
 * @author lj
 * @Description:
 * @date 2020-11-29 13:45
 * @QQ 851477108
 */

@Controller
public class ArchiveShowController {
    @Autowired
    private BlogService blogService;

    /**
     * 根据年份归档
     * @param model
     * @return
     */
    @GetMapping("/archives")
    public String archives(Model model){
        Map<String, List<Blog>> archiveMap = blogService.archiveBlog();
        int count = blogService.countBlog();
        model.addAttribute("archiveMap",archiveMap);
        model.addAttribute("blogCount",count);
        return "archives";
    }
}
